<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/animation.css">
    <style>
        body {
            height: 4000px;
        }

        .box {
            height: 1200px;
            background-color: rgb(228, 174, 174);
        }

        .img {
            width: 100%;
        }

        .animate {
            animation-play-state: paused;
        }

        .running {
            animation-play-state: running !important;
        }
    </style>
</head>

<body>
    <div class="box"></div>
    <div>
        <img class="img animate bounceIn " src="./img/html5_fit_peo.jpg" alt="">
    </div>

    <h2 class="animate fadeInDown">什么人适合学WEB全栈开发？</h2>


    <script>
        const animateEles = document.querySelectorAll('.animate')

        function running(ele) {
            ele.classList.add("running")
        }

        function isStart(ele) {
            return innerHeight - (ele.offsetTop - scrollY) - ele.offsetHeight >= showY
        }
        const showY = 100
        onscroll = function () {
            animateEles.forEach(function (ele) {
                let start = isStart(ele)
                if (start) {
                    running(ele)
                }
            })
        }
    </script>
</body>

</html>